<template>
    <components :is="getAllComponents()" v-bind="{ ...$attrs, data }" :keyName="data.key"></components>
</template>

<script>
export default {
    props: ['data'],
    data() {
        return {
        }
    },
    methods: {
        getAllComponents() {
            const ctx = require.context('./LowCode', true, /\.vue$/);
            let component = {};
            ctx.keys().forEach(key => {
                // 剥去文件名开头的 `./` 和`.vue`结尾的扩展名
                const module = key.replace(/^\.\//, '').replace(/\/index\.vue$/, '')
                if (module === (this.data.type[0].toUpperCase() + this.data.type.slice(1))) {
                    console.log(ctx(key).default)
                    component = ctx(key).default
                }
            });
            return component
        },
    }
}
</script>

<style></style>